﻿
using Abp.Application.Services.Dto;
using Abp.Web.Models;
using Abp.Web.Mvc.Authorization;
using KDS.Mes.Mes.Atlas;
using KDS.Mes.Mes.Atlas.Dtos;
using KDS.Mes.Web.Models.Atlass;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace KDS.Mes.Web.Controllers
{
    public class AtlasCpksController : Controller
    {
        private readonly IAtlasAppService _atlasAppService;
        private static DataSet gds;
        //考虑到图表的series数据为一个对象数组 这里额外定义一个series的类
        List<List<Series1>> seriesList3 = new List<List<Series1>>();
        List<Series1> seriesList1 = new List<Series1>();
        List<Series1> seriesList2 = new List<Series1>();

        List<AtlasListDto> pagedTasks;

        public AtlasCpksController(IAtlasAppService atlasAppService)
        {
            _atlasAppService = atlasAppService;

        }

        // GET: AtlasCpks
        public ActionResult Index()
        {

            var lines = new List<ComboboxItemDto>();
            lines.Insert(0, new ComboboxItemDto("", ""));
            lines.Insert(1, new ComboboxItemDto("X001", "一线"));
            lines.Insert(2, new ComboboxItemDto("X002", "二线"));
            lines.Insert(3, new ComboboxItemDto("X003", "三线"));

            var statinNos = new List<ComboboxItemDto>();
            statinNos.Insert(0, new ComboboxItemDto("", ""));
            statinNos.Insert(1, new ComboboxItemDto("S04", "S04"));
            statinNos.Insert(2, new ComboboxItemDto("S041", "S041"));
            statinNos.Insert(3, new ComboboxItemDto("S042", "S042"));
            statinNos.Insert(3, new ComboboxItemDto("S05", "S05"));
            statinNos.Insert(3, new ComboboxItemDto("S08", "S08"));
            statinNos.Insert(3, new ComboboxItemDto("S081", "S081"));
            statinNos.Insert(3, new ComboboxItemDto("S082", "S082"));
            statinNos.Insert(3, new ComboboxItemDto("S131", "S131"));
            statinNos.Insert(3, new ComboboxItemDto("S132", "S132"));

            var seatTypes = new List<ComboboxItemDto>();
            seatTypes.Insert(0, new ComboboxItemDto("", ""));
            seatTypes.Insert(1, new ComboboxItemDto("2", "2"));
            seatTypes.Insert(2, new ComboboxItemDto("M", "M"));
            seatTypes.Insert(3, new ComboboxItemDto("C", "C"));
            seatTypes.Insert(3, new ComboboxItemDto("D", "D"));

            var model = new AtlassViewModel
            {
                FilterText = Request.QueryString["filterText"],
                Lines = lines,
                StationNos = statinNos,
                SeatTypes = seatTypes
            };
            return View(model);
        }

        [DontWrapResult]
        public JsonResult GetAllAtlass(int limit, int offset, string sortName, string sortOrder,
                                     string lineId, string stationNoId, string seatID, DateTime? time1, DateTime? time2)
        {
            var sort = !string.IsNullOrEmpty(sortName) ? string.Format("{0} {1}", sortName, sortOrder) : "";
            var filter = new GetAtlasInput
            {
                SkipCount = offset,
                MaxResultCount = limit,
                Sorting = sort,
                LineId = lineId,
                StationNoId = stationNoId,
                SeatID = seatID,
                Time1 = time1,
                Time2 = time2,
            };
            var pagedTasks = _atlasAppService.GetPagedAtlass(filter);
            return Json(new { total = pagedTasks.TotalCount, rows = pagedTasks.Items }, JsonRequestBehavior.AllowGet);
        }
       

        [HttpPost]
        public JsonResult tb_DataSource(GetAtlasInput input)
        {
            List<JsonResult> lstJson = new List<JsonResult>();
            List<string> lstStr = new List<string>();
            DataTable dt = new DataTable("tb_source");
            for (int da = 0; da < 26; da++)
            {
                dt.Columns.Add("D" + da.ToString());
            }

            //string strWhere = "";
            //if (txtStartDate.Value.Trim().ToString().Length > 0)
            //{
            //    strWhere += string.Format(" and creat_time>'{0}' ", txtStartDate.Value.Trim().ToString());
            //}
            //if (txtEndDate.Value.Trim().ToString().Length > 0)
            //{
            //    strWhere += string.Format(" and creat_time<'{0}' ", txtEndDate.Value.Trim().ToString());
            //}
            //if (TXT_SEATCH.Text.Trim().ToString().Length > 0)
            //{
            //    strWhere += string.Format(" and SEAT_ID like '{0}%' ", TXT_SEATCH.Text.Trim().ToString());
            //}

            DataSet ds = new DataSet();
            pagedTasks = _atlasAppService.GetAtlass(input);
            //if (div_niujuqiang.Visible == true)
            //{
            //    ds = DBHelper.GetDataSet(string.Format("select * from V_N_ATLAS_RESULT where LINE='{0}' AND STATION_NO='{1}' and TIGHTENING_STATUS=1 and SEAT_ID LIKE '{2}%' {3} ", ddl1.SelectedValue, ddl2.SelectedValue, ddl3.SelectedValue, strWhere));
            //}


            DataTable dtNew = new DataTable("tb1");
            dtNew.Columns.Add("TORQUE");
       

            string[] s1 = new string[26];
            string[] s2 = new string[26];
            string[] s3 = new string[26];
            string[] s4 = new string[26];
            string[] s5 = new string[26];

            s1[0] = "1";
            s2[0] = "2";
            s3[0] = "3";
            s4[0] = "4";
            s5[0] = "5";

            int dtRow = 1;
            int ArrayNum = 1;

            if (pagedTasks != null)
            {
                for (int dtNum = 0; dtNum < pagedTasks.Count; dtNum++)
                {
                    if (dtNum < 125)
                    {
                        if (dtRow < 26)
                        {
                            switch (ArrayNum)
                            {
                                case 1:
                                    s1[dtRow] = String.Format("{0:N3}", (Convert.ToDouble(pagedTasks[dtNum].TORQUE.ToString()) / 1000));
                                    break;

                                case 2:
                                    s2[dtRow] = String.Format("{0:N3}", (Convert.ToDouble(pagedTasks[dtNum].TORQUE.ToString()) / 1000));
                                    break;

                                case 3:
                                    s3[dtRow] = String.Format("{0:N3}", (Convert.ToDouble(pagedTasks[dtNum].TORQUE.ToString()) / 1000));
                                    break;

                                case 4:
                                    s4[dtRow] = String.Format("{0:N3}", (Convert.ToDouble(pagedTasks[dtNum].TORQUE.ToString()) / 1000));
                                    break;

                                case 5:
                                    s5[dtRow] = String.Format("{0:N3}", (Convert.ToDouble(pagedTasks[dtNum].TORQUE.ToString()) / 1000));
                                    break;
                            }
                            ArrayNum = ArrayNum + 1;
                            if (ArrayNum > 5)
                            {
                                ArrayNum = 1;
                                dtRow = dtRow + 1;
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            for (int s = 1; s < 6; s++)
            {
                DataRow dr = dt.NewRow();
                for (int i = 0; i < 26; i++)
                {
                    switch (s)
                    {
                        case 1:
                            dr["D" + i.ToString()] = s1[i] == null ? "0.0" : s1[i].ToString();
                            break;

                        case 2:
                            dr["D" + i.ToString()] = s2[i] == null ? "0.0" : s2[i].ToString();
                            break;

                        case 3:
                            dr["D" + i.ToString()] = s3[i] == null ? "0.0" : s3[i].ToString();
                            break;

                        case 4:
                            dr["D" + i.ToString()] = s4[i] == null ? "0.0" : s4[i].ToString();
                            break;

                        case 5:
                            dr["D" + i.ToString()] = s5[i] == null ? "0.0" : s5[i].ToString();
                            break;
                    }
                }
                dt.Rows.Add(dr);
            }

            StringBuilder sb = new StringBuilder();
            sb.Append("<table style=\"width:100%; margin:0 auto;text-align:center;border-collapse:collapse;font-size:12px;\">");

            #region 标题部分

            sb.Append("<tr style=\"background-color:#63cbb5;\">");
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px;\">样本序列</td>");
            for (int i = 1; i < 26; i++)
            {
                sb.Append("<td style=\"border:1px solid #ccc;padding:5px;\">" + i.ToString() + "</td>");
            }
            sb.Append("</tr>");

            #endregion 标题部分

            #region 数据部分

            for (int dColumn = 0; dColumn < dt.Rows.Count; dColumn++)
            {
                sb.Append("<tr>");
                if (dColumn == 0)
                {
                    sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\" rowspan='" + dt.Rows.Count.ToString() + "'>数据</td>");
                }
                for (int dr = 0; dr < 26; dr++)
                {
                    sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + dt.Rows[dColumn]["D" + dr.ToString()].ToString() + "</td>");
                }
                sb.Append("</tr>");
            }

            #endregion 数据部分

            #region Total

            sb.Append("<tr style=\"background-color:#fff;\">");
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">TOTAL</td>");
            for (int tt = 1; tt < 26; tt++)
            {
                double total = 0.00;
                foreach (DataRow dr in dt.Rows)
                {
                    total += double.Parse(dr["D" + tt.ToString()].ToString());
                }
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", total) + "</td>");
            }
            sb.Append("</tr>");

            #endregion Total

            #region AVERAGE(X)

            double average_sum = 0.00;//获取AVERAGE平均数的合
            double max_min_sum = 0.00;//获取max_min平均数的合
            sb.Append("<tr style=\"background-color:#63cbb5;\">");
            double[] i_char1_AVERAGE = new double[25];//声明数组
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">AVERAGE(X)</td>");
            for (int aa = 1; aa < 26; aa++)
            {
                double total = 0.00;
                double average = 0.00;
                foreach (DataRow dr in dt.Rows)
                {
                    total += double.Parse(dr["D" + aa.ToString()].ToString());
                }
                average = double.Parse((total / dt.Rows.Count).ToString());
                i_char1_AVERAGE[(aa - 1)] = Convert.ToDouble(String.Format("{0:F}", average));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", average) + "</td>");
                average_sum += average;
            }
            sb.Append("</tr>");

            #endregion AVERAGE(X)

            #region CLX

            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            double[] i_char1_CLX = new double[25];//声明数组
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">CLX</td>");
            for (int cc = 1; cc < 26; cc++)
            {
                double clx = average_sum / 25;//获取AVERAGE平均数
                i_char1_CLX[(cc - 1)] = Convert.ToDouble(String.Format("{0:F}", clx));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", clx) + "</td>");
            }
            sb.Append("</tr>");

            #endregion CLX

            string content = string.Empty;
            double[] i_char2_MAX_MIN = new double[25];//声明数组
            maxMin(dt, ref max_min_sum, ref content, ref i_char2_MAX_MIN);

            #region UCLX

            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            double[] i_char1_UCLX = new double[25];//声明数组
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">UCLX</td>");
            for (int uu = 1; uu < 26; uu++)
            {
                double aveClx = average_sum / 25;//获取AVERAGE平均数
                double maxClr = max_min_sum / 25;
                double uclx = aveClx + maxClr * 0.73;
                i_char1_UCLX[(uu - 1)] = Convert.ToDouble(String.Format("{0:F}", uclx));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", uclx) + "</td>");
            }

            sb.Append("</tr>");

            #endregion UCLX

            #region LCLX

            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            double[] i_char1_LCLX = new double[25];//声明数组
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">LCLX</td>");
            for (int ll = 1; ll < 26; ll++)
            {
                double aveClx = average_sum / 25;//获取AVERAGE平均数
                double maxClr = max_min_sum / 25;
                double lclx = aveClx - maxClr * 0.73;
                i_char1_LCLX[(ll - 1)] = Convert.ToDouble(String.Format("{0:F}", lclx));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", lclx) + "</td>");
            }
            sb.Append("</tr>");

            #endregion LCLX

            #region MAX-MIN(R)

            sb.Append(content);

            #endregion MAX-MIN(R)

            #region CLR

            double[] i_char2_CLR = new double[25];//声明数组
            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            int[] idobule = new int[25];
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">CLR</td>");
            for (int cc = 1; cc < 26; cc++)
            {
                double clr = max_min_sum / 25;
                i_char2_CLR[(cc - 1)] = Convert.ToDouble(String.Format("{0:F}", clr));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", clr) + "</td>");
            }
            sb.Append("</tr>");

            #endregion CLR

            #region UCLR

            double[] i_char2_UCLR = new double[25];//声明数组
            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">UCLR</td>");
            for (int uu = 1; uu < 26; uu++)
            {
                double maxUclr = max_min_sum / 25;
                double uclr = maxUclr * 2.28;
                i_char2_UCLR[(uu - 1)] = Convert.ToDouble(String.Format("{0:F}", uclr));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", uclr) + "</td>");
            }
            sb.Append("</tr>");

            #endregion UCLR

            #region LCLR

            double[] i_char2_LCLR = new double[25];//声明数组
            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">LCLR</td>");
            for (int ll = 1; ll < 26; ll++)
            {
                double maxLclr = max_min_sum / 25;
                double lclr = 0 * maxLclr;
                i_char2_LCLR[(ll - 1)] = Convert.ToDouble(String.Format("{0:F}", lclr));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", lclr) + "</td>");
            }
            sb.Append("</tr>");

            #endregion LCLR

            sb.Append("</table>");
            lstStr.Add(sb.ToString());
            //div_Content.InnerHtml = sb.ToString();

            #region 折线图一


            Series1 seriesObj1 = new Series1();
            seriesObj1.id = 1;
            seriesObj1.name = "AVERAGE(X)";
            seriesObj1.type = "line"; //线性图呈现
            seriesObj1.data = new List<Data>(); //先初始化 不初始化后面直直接data.Add(x)会报错
            seriesObj1.symbol = "circle";
            seriesObj1.symbolSize = 3;
            seriesObj1.lineStyle = new LineStyle(new NormalLine(1));

            //var result_15 = result.Where(x => x.Angle == "15").ToList();
            for (int i = 0; i < i_char1_AVERAGE.Length; i++)
            {
                seriesObj1.data.Add(new Data() { value = i_char1_AVERAGE[i] });
            }
            seriesList1.Add(seriesObj1);

            Series1 seriesObj2 = new Series1();
            seriesObj2.id = 2;
            seriesObj2.name = "UCLX";
            seriesObj2.type = "line"; //线性图呈现
            seriesObj2.data = new List<Data>(); //先初始化 不初始化后面直直接data.Add(x)会报错
            seriesObj2.symbol = "circle";
            seriesObj2.symbolSize = 3;
            seriesObj2.lineStyle = new LineStyle(new NormalLine(1));

            //var result_15 = result.Where(x => x.Angle == "15").ToList();
            for (int i = 0; i < i_char1_CLX.Length; i++)
            {
                seriesObj2.data.Add(new Data() { value = i_char1_CLX[i] });
            }
            seriesList1.Add(seriesObj2);

            Series1 seriesObj3 = new Series1();
            seriesObj3.id = 3;
            seriesObj3.name = "CLX";
            seriesObj3.type = "line"; //线性图呈现
            seriesObj3.data = new List<Data>(); //先初始化 不初始化后面直直接data.Add(x)会报错
            seriesObj3.symbol = "circle";
            seriesObj3.symbolSize = 3;
            seriesObj3.lineStyle = new LineStyle(new NormalLine(1));

            //var result_15 = result.Where(x => x.Angle == "15").ToList();
            for (int i = 0; i < i_char1_UCLX.Length; i++)
            {
                seriesObj3.data.Add(new Data() { value = i_char1_UCLX[i] });
            }
            seriesList1.Add(seriesObj3);

            Series1 seriesObj4 = new Series1();
            seriesObj4.id = 4;
            seriesObj4.name = "LCLX";
            seriesObj4.type = "line"; //线性图呈现
            seriesObj4.data = new List<Data>(); //先初始化 不初始化后面直直接data.Add(x)会报错
            seriesObj4.symbol = "circle";
            seriesObj4.symbolSize = 3;
            seriesObj4.lineStyle = new LineStyle(new NormalLine(1));

            //var result_15 = result.Where(x => x.Angle == "15").ToList();
            for (int i = 0; i < i_char1_LCLX.Length; i++)
            {
                seriesObj4.data.Add(new Data() { value = i_char1_LCLX[i] });
            }
            seriesList1.Add(seriesObj4);

            seriesList3.Add(seriesList1);
            //lstJson.Add(Json(seriesList));

            #endregion 折线图一

            #region 折线图二


            Series1 seriesObj5 = new Series1();
            seriesObj5.id = 1;
            seriesObj5.name = "MAX-MIN(R)";
            seriesObj5.type = "line"; //线性图呈现
            seriesObj5.data = new List<Data>(); //先初始化 不初始化后面直直接data.Add(x)会报错
            seriesObj5.symbol = "circle";
            seriesObj5.symbolSize = 3;
            seriesObj5.lineStyle = new LineStyle(new NormalLine(1));

            //var result_15 = result.Where(x => x.Angle == "15").ToList();
            for (int i = 0; i < i_char2_MAX_MIN.Length; i++)
            {
                seriesObj5.data.Add(new Data() { value = i_char2_MAX_MIN[i] });
            }
            seriesList2.Add(seriesObj5);

            Series1 seriesObj6 = new Series1();
            seriesObj6.id = 2;
            seriesObj6.name = "CLR";
            seriesObj6.type = "line"; //线性图呈现
            seriesObj6.data = new List<Data>(); //先初始化 不初始化后面直直接data.Add(x)会报错
            seriesObj6.symbol = "circle";
            seriesObj6.symbolSize = 3;
            seriesObj6.lineStyle = new LineStyle(new NormalLine(1));

            //var result_15 = result.Where(x => x.Angle == "15").ToList();
            for (int i = 0; i < i_char2_CLR.Length; i++)
            {
                seriesObj6.data.Add(new Data() { value = i_char2_CLR[i] });
            }
            seriesList2.Add(seriesObj6);

            Series1 seriesObj7 = new Series1();
            seriesObj7.id = 3;
            seriesObj7.name = "UCLR";
            seriesObj7.type = "line"; //线性图呈现
            seriesObj7.data = new List<Data>(); //先初始化 不初始化后面直直接data.Add(x)会报错
            seriesObj7.symbol = "circle";
            seriesObj7.symbolSize = 3;
            seriesObj7.lineStyle = new LineStyle(new NormalLine(1));

            //var result_15 = result.Where(x => x.Angle == "15").ToList();
            for (int i = 0; i < i_char2_UCLR.Length; i++)
            {
                seriesObj7.data.Add(new Data() { value = i_char2_UCLR[i] });
            }
            seriesList2.Add(seriesObj7);

            Series1 seriesObj8 = new Series1();
            seriesObj8.id = 4;
            seriesObj8.name = "LCLR";
            seriesObj8.type = "line"; //线性图呈现
            seriesObj8.data = new List<Data>(); //先初始化 不初始化后面直直接data.Add(x)会报错
            seriesObj8.symbol = "circle";
            seriesObj8.symbolSize = 3;
            seriesObj8.lineStyle = new LineStyle(new NormalLine(1));

            //var result_15 = result.Where(x => x.Angle == "15").ToList();
            for (int i = 0; i < i_char2_LCLR.Length; i++)
            {
                seriesObj8.data.Add(new Data() { value = i_char2_LCLR[i] });
            }
            seriesList2.Add(seriesObj8);
            seriesList3.Add(seriesList2);

            #endregion 折线图二

            #region 说明栏底部的函数

            sb = new StringBuilder();
            sb.Append("<table style=\"width:100%;text-align:center;border-collapse:collapse;font-size:12px;\">");
            sb.Append("<tr>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">=Min(</td>");
            double clx_ex = average_sum / 25;//获取AVERAGE平均数
            double clr_ex = max_min_sum / 25;
            double ex = (5.5 - clx_ex) / (3 * clr_ex / 2.06);
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", ex) + "</td>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">||</td>");
            double clx_ex1 = average_sum / 25;
            double clr_ex1 = max_min_sum / 25;
            double ex1 = (clx_ex1 - 4.5) / (3 * clr_ex1 / 2.06);
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", ex1) + "</td>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">)=</td>");
            double min_ex_ex1 = Math.Min(ex, ex1);
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc: text-align:center:\">" + string.Format("{0:F}", min_ex_ex1) + "</td>");
            sb.Append("</tr>");
            sb.Append("</table>");
            //explain2.InnerHtml = sb.ToString();
            lstStr.Add(sb.ToString());
            #endregion 说明栏底部的函数

            #region 折线图一上面的函数

            sb = new StringBuilder();
            sb.Append("<table style=\"width:100%;text-align:center;border-collapse:collapse;font-size:12px;\">");
            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">X=AVE（X）=</td>");
            double chart1up_clx = average_sum / 25;
            sb.Append("<td style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", chart1up_clx) + "</td>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">UCLX=X+A2R=</td>");
            double chart1up_aveClx = average_sum / 25;
            double chart1up_maxClr = max_min_sum / 25;
            double chart1up_uclx = chart1up_aveClx + chart1up_maxClr * 0.73;
            sb.Append("<td style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", chart1up_uclx) + "</td>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">LCLX=X-A2R=</td>");
            double chart1up_aveClx1 = average_sum / 25;
            double chart1up_maxClr1 = max_min_sum / 25;
            double chart1up_lclx = chart1up_aveClx1 - chart1up_maxClr1 * 0.73;
            sb.Append("<td style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", chart1up_lclx) + "</td>");
            sb.Append("</tr>");
            sb.Append("</table>");
            //chart1up.InnerHtml = sb.ToString();
            lstStr.Add(sb.ToString());
            #endregion 折线图一上面的函数

            #region 折线图二上面的函数

            sb = new StringBuilder();
            sb.Append("<table style=\"width:100%;text-align:center;border-collapse:collapse;font-size:12px;\">");
            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">X=AVE（X）=</td>");
            double chart2up_clr = max_min_sum / 25;
            sb.Append("<td style=\"border:0px solid #ccc; text-align;center;\">" + String.Format("{0:F}", chart2up_clr) + "</td>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">UCLX=X+A2R=</td>");
            double chart2up_maxUclr = max_min_sum / 25;
            double chart2up_uclr = chart2up_maxUclr * 2.28;
            sb.Append("<td style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", chart2up_uclr) + "</td>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">LCLX=X-A2R=</td>");
            double chart2up_maxLclr = max_min_sum / 25;
            double chart2up_lclr = 0 * chart2up_maxLclr;
            sb.Append("<td style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", chart2up_lclr) + "</td>");
            sb.Append("</tr>");
            sb.Append("</table>");
            //chart2up.InnerHtml = sb.ToString();
            lstStr.Add(sb.ToString());
            #endregion 折线图二上面的函数

            #region 网页标题
            var temp = string.Empty;


            #endregion

            lstJson.Add(Json(lstStr));

            var newObj = new
            {

                series = seriesList3,
                lststr = lstStr
                //legend = legendList,
                //grid = _grid
            };
            return Json(newObj, JsonRequestBehavior.AllowGet);
        }

        private void PageLoad(DataTable dts)
        {
            DataTable dt = dts;
            StringBuilder sb = new StringBuilder();
            sb.Append("<table style=\"width:100%; margin:0 auto;text-align:center;border-collapse:collapse;font-size:12px;\">");

            #region 标题部分

            sb.Append("<tr style=\"background-color:#63cbb5;\">");
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px;\">样本序列</td>");
            for (int i = 1; i < 26; i++)
            {
                sb.Append("<td style=\"border:1px solid #ccc;padding:5px;\">" + i.ToString() + "</td>");
            }
            sb.Append("</tr>");

            #endregion 标题部分

            #region 数据部分

            for (int dColumn = 0; dColumn < dt.Rows.Count; dColumn++)
            {
                sb.Append("<tr>");
                if (dColumn == 0)
                {
                    sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\" rowspan='" + dt.Rows.Count.ToString() + "'>数据</td>");
                }
                for (int dr = 0; dr < 26; dr++)
                {
                    sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + dt.Rows[dColumn]["D" + dr.ToString()].ToString() + "</td>");
                }
                sb.Append("</tr>");
            }

            #endregion 数据部分

            #region Total

            sb.Append("<tr style=\"background-color:#fff;\">");
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">TOTAL</td>");
            for (int tt = 1; tt < 26; tt++)
            {
                double total = 0.00;
                foreach (DataRow dr in dt.Rows)
                {
                    total += double.Parse(dr["D" + tt.ToString()].ToString());
                }
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", total) + "</td>");
            }
            sb.Append("</tr>");

            #endregion Total

            #region AVERAGE(X)

            double average_sum = 0.00;//获取AVERAGE平均数的合
            double max_min_sum = 0.00;//获取max_min平均数的合
            sb.Append("<tr style=\"background-color:#63cbb5;\">");
            double[] i_char1_AVERAGE = new double[25];//声明数组
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">AVERAGE(X)</td>");
            for (int aa = 1; aa < 26; aa++)
            {
                double total = 0.00;
                double average = 0.00;
                foreach (DataRow dr in dt.Rows)
                {
                    total += double.Parse(dr["D" + aa.ToString()].ToString());
                }
                average = double.Parse((total / dt.Rows.Count).ToString());
                i_char1_AVERAGE[(aa - 1)] = Convert.ToDouble(String.Format("{0:F}", average));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", average) + "</td>");
                average_sum += average;
            }
            sb.Append("</tr>");

            #endregion AVERAGE(X)

            #region CLX

            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            double[] i_char1_CLX = new double[25];//声明数组
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">CLX</td>");
            for (int cc = 1; cc < 26; cc++)
            {
                double clx = average_sum / 25;//获取AVERAGE平均数
                i_char1_CLX[(cc - 1)] = Convert.ToDouble(String.Format("{0:F}", clx));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", clx) + "</td>");
            }
            sb.Append("</tr>");

            #endregion CLX

            string content = string.Empty;
            double[] i_char2_MAX_MIN = new double[25];//声明数组
            //maxMin(dt, ref max_min_sum, ref content, ref i_char2_MAX_MIN);

            #region UCLX

            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            double[] i_char1_UCLX = new double[25];//声明数组
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">UCLX</td>");
            for (int uu = 1; uu < 26; uu++)
            {
                double aveClx = average_sum / 25;//获取AVERAGE平均数
                double maxClr = max_min_sum / 25;
                double uclx = aveClx + maxClr * 0.73;
                i_char1_UCLX[(uu - 1)] = Convert.ToDouble(String.Format("{0:F}", uclx));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", uclx) + "</td>");
            }

            sb.Append("</tr>");

            #endregion UCLX

            #region LCLX

            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            double[] i_char1_LCLX = new double[25];//声明数组
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">LCLX</td>");
            for (int ll = 1; ll < 26; ll++)
            {
                double aveClx = average_sum / 25;//获取AVERAGE平均数
                double maxClr = max_min_sum / 25;
                double lclx = aveClx - maxClr * 0.73;
                i_char1_LCLX[(ll - 1)] = Convert.ToDouble(String.Format("{0:F}", lclx));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", lclx) + "</td>");
            }
            sb.Append("</tr>");

            #endregion LCLX

            #region MAX-MIN(R)

            sb.Append(content);

            #endregion MAX-MIN(R)

            #region CLR

            double[] i_char2_CLR = new double[25];//声明数组
            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            int[] idobule = new int[25];
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">CLR</td>");
            for (int cc = 1; cc < 26; cc++)
            {
                double clr = max_min_sum / 25;
                i_char2_CLR[(cc - 1)] = Convert.ToDouble(String.Format("{0:F}", clr));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", clr) + "</td>");
            }
            sb.Append("</tr>");

            #endregion CLR

            #region UCLR

            double[] i_char2_UCLR = new double[25];//声明数组
            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">UCLR</td>");
            for (int uu = 1; uu < 26; uu++)
            {
                double maxUclr = max_min_sum / 25;
                double uclr = maxUclr * 2.28;
                i_char2_UCLR[(uu - 1)] = Convert.ToDouble(String.Format("{0:F}", uclr));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", uclr) + "</td>");
            }
            sb.Append("</tr>");

            #endregion UCLR

            #region LCLR

            double[] i_char2_LCLR = new double[25];//声明数组
            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">LCLR</td>");
            for (int ll = 1; ll < 26; ll++)
            {
                double maxLclr = max_min_sum / 25;
                double lclr = 0 * maxLclr;
                i_char2_LCLR[(ll - 1)] = Convert.ToDouble(String.Format("{0:F}", lclr));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", lclr) + "</td>");
            }
            sb.Append("</tr>");

            #endregion LCLR

            sb.Append("</table>");
            //div_Content.InnerHtml = sb.ToString();

            #region 折线图一

            DataTable dtJson = new DataTable();
            dtJson.Columns.Add("name");
            dtJson.Columns.Add("type");
            //dtJson.Columns.Add("stack");
            dtJson.Columns.Add("data", typeof(object));

            //这里是给DataTable添加数据
            DataRow dr1_chart = dtJson.NewRow();
            dr1_chart["name"] = "AVERAGE(X)";
            dr1_chart["type"] = "line";
            //dr1_chart["stack"] = "总量";
            dr1_chart["data"] = i_char1_AVERAGE;//将数组对象写入到DataTable中
            dtJson.Rows.Add(dr1_chart);

            DataRow dr2_chart = dtJson.NewRow();
            dr2_chart["name"] = "CLX";
            dr2_chart["type"] = "line";
            //dr2_chart["stack"] = "总量";
            dr2_chart["data"] = i_char1_CLX;//将数组对象写入到DataTable中
            dtJson.Rows.Add(dr2_chart);

            DataRow dr3_chart = dtJson.NewRow();
            dr3_chart["name"] = "UCLX";
            dr3_chart["type"] = "line";
            //dr3_chart["stack"] = "总量";
            dr3_chart["data"] = i_char1_UCLX;//将数组对象写入到DataTable中
            dtJson.Rows.Add(dr3_chart);

            DataRow dr4_chart = dtJson.NewRow();
            dr4_chart["name"] = "LCLX";
            dr4_chart["type"] = "line";
            //dr4_chart["stack"] = "总量";
            dr4_chart["data"] = i_char1_LCLX;//将数组对象写入到DataTable中
            dtJson.Rows.Add(dr4_chart);

            string strMyChart1DATA = "var myChart1Data=";
            strMyChart1DATA += Newtonsoft.Json.JsonConvert.SerializeObject(dtJson);
            Response.Write(string.Format("<script>{0}</script>", strMyChart1DATA));

            #endregion 折线图一

            #region 折线图二

            DataTable dtJson2 = new DataTable();
            dtJson2.Columns.Add("name");
            dtJson2.Columns.Add("type");
            //dtJson2.Columns.Add("stack");
            dtJson2.Columns.Add("data", typeof(object));

            DataRow dr1_chart2 = dtJson2.NewRow();
            dr1_chart2["name"] = "MAX-MIN(R)";
            dr1_chart2["type"] = "line";
            //dr1_chart2["stack"] = "总量";
            dr1_chart2["data"] = i_char2_MAX_MIN;
            dtJson2.Rows.Add(dr1_chart2);

            DataRow dr2_chart2 = dtJson2.NewRow();
            dr2_chart2["name"] = "CLR";
            dr2_chart2["type"] = "line";
            //dr2_chart2["stack"] = "总量";
            dr2_chart2["data"] = i_char2_CLR;
            dtJson2.Rows.Add(dr2_chart2);

            DataRow dr3_chart2 = dtJson2.NewRow();
            dr3_chart2["name"] = "UCLR";
            dr3_chart2["type"] = "line";
            //dr3_chart2["stack"] = "总量";
            dr3_chart2["data"] = i_char2_UCLR;
            dtJson2.Rows.Add(dr3_chart2);

            DataRow dr4_chart2 = dtJson2.NewRow();
            dr4_chart2["name"] = "LCLR";
            dr4_chart2["type"] = "line";
            //dr4_chart2["stack"] = "总量";
            dr4_chart2["data"] = i_char2_LCLR;
            dtJson2.Rows.Add(dr4_chart2);

            string strMyChart2DATA2 = "var myChart2Data=";
            strMyChart2DATA2 += Newtonsoft.Json.JsonConvert.SerializeObject(dtJson2);
            Response.Write(string.Format("<script>{0}</script>", strMyChart2DATA2));

            #endregion 折线图二

            #region 说明栏底部的函数

            sb = new StringBuilder();
            sb.Append("<table style=\"width:100%;text-align:center;border-collapse:collapse;font-size:12px;\">");
            sb.Append("<tr>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">=Min(</td>");
            double clx_ex = average_sum / 25;//获取AVERAGE平均数
            double clr_ex = max_min_sum / 25;
            double ex = (5.5 - clx_ex) / (3 * clr_ex / 2.06);
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", ex) + "</td>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">||</td>");
            double clx_ex1 = average_sum / 25;
            double clr_ex1 = max_min_sum / 25;
            double ex1 = (clx_ex1 - 4.5) / (3 * clr_ex1 / 2.06);
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", ex1) + "</td>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">)=</td>");
            double min_ex_ex1 = Math.Min(ex, ex1);
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc: text-align:center:\">" + string.Format("{0:F}", min_ex_ex1) + "</td>");
            sb.Append("</tr>");
            sb.Append("</table>");
            //explain2.InnerHtml = sb.ToString();

            #endregion 说明栏底部的函数

            #region 折线图一上面的函数

            sb = new StringBuilder();
            sb.Append("<table style=\"width:100%;text-align:center;border-collapse:collapse;font-size:12px;\">");
            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">X=AVE（X）=</td>");
            double chart1up_clx = average_sum / 25;
            sb.Append("<td style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", chart1up_clx) + "</td>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">UCLX=X+A2R=</td>");
            double chart1up_aveClx = average_sum / 25;
            double chart1up_maxClr = max_min_sum / 25;
            double chart1up_uclx = chart1up_aveClx + chart1up_maxClr * 0.73;
            sb.Append("<td style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", chart1up_uclx) + "</td>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">LCLX=X-A2R=</td>");
            double chart1up_aveClx1 = average_sum / 25;
            double chart1up_maxClr1 = max_min_sum / 25;
            double chart1up_lclx = chart1up_aveClx1 - chart1up_maxClr1 * 0.73;
            sb.Append("<td style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", chart1up_lclx) + "</td>");
            sb.Append("</tr>");
            sb.Append("</table>");
            //chart1up.InnerHtml = sb.ToString();

            #endregion 折线图一上面的函数

            #region 折线图二上面的函数

            sb = new StringBuilder();
            sb.Append("<table style=\"width:100%;text-align:center;border-collapse:collapse;font-size:12px;\">");
            sb.Append("<tr style=\"background-color:#EEE8AA;\">");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">X=AVE（X）=</td>");
            double chart2up_clr = max_min_sum / 25;
            sb.Append("<td style=\"border:0px solid #ccc; text-align;center;\">" + String.Format("{0:F}", chart2up_clr) + "</td>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">UCLX=X+A2R=</td>");
            double chart2up_maxUclr = max_min_sum / 25;
            double chart2up_uclr = chart2up_maxUclr * 2.28;
            sb.Append("<td style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", chart2up_uclr) + "</td>");
            sb.Append("<td colspan='2' style=\"border:0px solid #ccc; text-align;center;\">LCLX=X-A2R=</td>");
            double chart2up_maxLclr = max_min_sum / 25;
            double chart2up_lclr = 0 * chart2up_maxLclr;
            sb.Append("<td style=\"border:0px solid #ccc; text-align;center;\">" + string.Format("{0:F}", chart2up_lclr) + "</td>");
            sb.Append("</tr>");
            sb.Append("</table>");
            //chart2up.InnerHtml = sb.ToString();

            #endregion 折线图二上面的函数

            #region 网页标题
            var temp = string.Empty;


            #endregion
        }


        private void maxMin(DataTable dt, ref double maxMinSum, ref string maxContent, ref double[] i_char2_MAX_MIN)
        {
            StringBuilder sb = new StringBuilder();
            maxMinSum = 0;

            #region MAX-MIN(R)

            sb.Append("<tr style=\"background-color:#63cbb5;\">");
            sb.Append("<td colspan='2' style=\"border:1px solid #ccc; padding:5px; text-align;center;\">MAX-MIN(R)</td>");
            for (int mm = 1; mm < 26; mm++)
            {
                DataRow[] drs_desc = dt.Select("", " D" + mm.ToString() + " desc ");
                double drs_desc_max = double.Parse(drs_desc[0]["D" + mm.ToString()].ToString());
                DataRow[] drs_asc = dt.Select("", " D" + mm.ToString() + " asc ");
                double drs_asc_min = double.Parse(drs_asc[0]["D" + mm.ToString()].ToString());
                i_char2_MAX_MIN[(mm - 1)] = Convert.ToDouble(String.Format("{0:F}", (drs_desc_max - drs_asc_min)));
                sb.Append("<td style=\"border:1px solid #ccc; padding:5px;\">" + String.Format("{0:F}", double.Parse((drs_desc_max - drs_asc_min).ToString())) + "</td>");
                maxMinSum += drs_desc_max - drs_asc_min;
            }
            sb.Append("</tr>");

            #endregion MAX-MIN(R)

            maxContent = sb.ToString();
        }


        //[HttpPost]
        //private void Export()
        //{
        //    var a = 1;
        //}

        [HttpGet]
        public FileResult Export(GetAtlasInput input)
        {
          
            #region 导出重命名

            string filepath = "";
            string strDateTimeArea = "-";

            pagedTasks = _atlasAppService.GetAtlass(input);
            //if (TXT_SEATCH.Text.Trim().ToString() != "")
            //{
            //    if (strDateTimeArea == "-")
            //    {
            //        strDateTimeArea = "";
            //    }
            //    strDateTimeArea += "-";
            //    strDateTimeArea += TXT_SEATCH.Text.Trim().ToString();
            //}

            //if (txtStartDate.Value.Trim().ToString() != "")
            //{
            //    if (strDateTimeArea == "-")
            //    {
            //        strDateTimeArea = "";
            //    }
            //    strDateTimeArea += "-";
            //    strDateTimeArea += Convert.ToDateTime(txtStartDate.Value.Trim().ToString()).ToString("yyyy年MM月dd日HH时mm分ss秒");
            //}

            //if (txtEndDate.Value.Trim().ToString() != "")
            //{
            //    if (strDateTimeArea == "-")
            //    {
            //        strDateTimeArea = "";
            //    }
            //    strDateTimeArea += "-";
            //    strDateTimeArea += Convert.ToDateTime(txtEndDate.Value.Trim().ToString()).ToString("yyyy年MM月dd日HH时mm分ss秒");
            //}

            //if (div_niujuqiang.Visible == true)
            //{
            //    filepath = Server.MapPath(Request.ApplicationPath) + @"Export\扭矩枪报表信息-" + ddl1.SelectedValue.Trim().ToString() + "-" + ddl2.SelectedValue.Trim().ToString() + strDateTimeArea + ".xls";
            //}

            //if (div_sanxian.Visible == true)
            //{
            //    filepath = Server.MapPath(Request.ApplicationPath) + @"Export\扭矩枪报表信息-" + ddl4.SelectedValue.Trim().ToString() + "-" + ddl5.SelectedValue.Trim().ToString() + strDateTimeArea + ".xls";
            //}
            //filepath = Server.MapPath(Request.ApplicationPath) + @"Export\扭矩枪报表信息-" + DateTime.Now.ToString("yyyyMMddHHmmss")+ ".xls";
            filepath = Server.MapPath(Request.ApplicationPath) + @"Content\Mould\扭矩枪报表信息-111.xls";
            #endregion 导出重命名

            System.IO.FileInfo file = new System.IO.FileInfo(filepath);
            string templatePath = Server.MapPath(Request.ApplicationPath) + @"Content\Mould\扭矩枪报表.xls";
            NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(templatePath, FileMode.Open));
            NPOI.SS.UserModel.ISheet sheet = book.GetSheet("sheet1");
            //DataTable dt = gds.Tables[0];
            int dtNum = 0;
            for (int j = 0; j < 25; j++)
            {
                for (int i = 0; i < 5; i++)
                {
                    double d = 0;
                    if (pagedTasks.Count != 0)
                    {
                        if (dtNum < pagedTasks.Count)
                        {
                            //if (dt.Rows[dtNum] != null)
                            //{
                            if (pagedTasks[dtNum].TORQUE != null)
                            {
                                double.TryParse(pagedTasks[dtNum].TORQUE.ToString(), out d);
                            }
                            //}
                        }
                    }

                    d = d / 1000;
                    sheet.GetRow(i + 30).GetCell(j + 3).SetCellValue(d);
                    dtNum++;
                }
            }
            sheet.ForceFormulaRecalculation = true;

            #region excel标题
            //var temp = string.Empty;

            //if (ddl1.SelectedItem.Text == "一线")
            //{
            //    if (ddl2.SelectedItem.Text == "S041" || ddl2.SelectedItem.Text == "S042")
            //    {
            //        temp = "把扣";
            //    }
            //    else if (ddl2.SelectedItem.Text == "S08")
            //    {
            //        temp = "座垫";
            //    }
            //    else if (ddl2.SelectedItem.Text == "S131" || ddl2.SelectedItem.Text == "S132")
            //    {
            //        temp = "靠背";
            //    }
            //}
            //else if (ddl1.SelectedItem.Text == "二线")
            //{
            //    if (ddl2.SelectedItem.Text == "S04")
            //    {
            //        temp = "把扣";
            //    }
            //    else if (ddl2.SelectedItem.Text == "S081" || ddl2.SelectedItem.Text == "S082")
            //    {
            //        temp = "靠背";
            //    }
            //}
            sheet.GetRow(1).GetCell(4).SetCellValue(input.LineId);
            //sheet.GetRow(1).GetCell(9).SetCellValue(temp);
            sheet.GetRow(2).GetCell(4).SetCellValue(input.SeatTypeId);
            sheet.GetRow(2).GetCell(9).SetCellValue(input.StationNoId);
            #endregion

            Stream s = new FileStream(file.FullName, FileMode.OpenOrCreate);
            MemoryStream ms = new MemoryStream();
            s.Close();
            //book.ForceFormulaRecalculation = true;
            //book.Write(s);
            //book.Close();
            //s.Close();
            //Response.Clear();

            //System.IO.MemoryStream ms = new System.IO.MemoryStream();
            book.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);
            return File(ms, "application/vnd.ms-excel", "扭矩枪报表信息 - " + DateTime.Now.ToString("yyyyMMddHHmmss")+ ".xls");

        }

    }


    public class Series1
    {
        /// <summary>
        /// sereis序列组id
        /// </summary>
        public int id { get; set; }

        /// <summary>
        /// series序列组名称
        /// </summary>
        public string name { get; set; }

        /// <summary>
        /// series序列组呈现图表类型(line、column、bar等)
        /// </summary>
        public string type { get; set; }

        /// <summary>
        /// series序列组的数据为数据类型数组
        /// </summary>
        public List<Data> data { get; set; }

        /// <summary>
        /// 节点样式
        /// </summary>
        public string symbol { get; set; }

        public int symbolSize { get; set; }

        /// <summary>
        /// 线条样式
        /// </summary>
        public LineStyle lineStyle { get; set; }
    }

    public class Data
    {
        /// <summary>
        /// value值
        /// </summary>
        public object value { get; set; }

        ///// <summary>
        ///// 单个拐点标志的样式设置。
        ///// </summary>
        //public ItemStyle itemStyle { get; set; }
    }

    public class ItemStyle
    {
        // 此构造函数为属性类指定未命名的参数。
        public ItemStyle(Normal _normal)
        {
            this.normal = _normal;
        }
        /// <summary>
        /// 单个拐点标志的样式设置。
        /// </summary>
        public Normal normal { get; set; }
    }

    public class Normal
    {
        // 此构造函数为属性类指定未命名的参数。
        public Normal(string _color, int _width)
        {
            this.color = _color;
            this.width = _width;
        }

        /// <summary>
        /// 节点颜色
        /// </summary>
        public string color { get; set; }

        public int width { get; set; }

    }

    public class NormalLine
    {
        // 此构造函数为属性类指定未命名的参数。
        public NormalLine(int _width)
        {
            this.width = _width;
        }

        public int width { get; set; }

    }

    public class LineStyle
    {
        // 此构造函数为属性类指定未命名的参数。
        public LineStyle(NormalLine _normal)
        {
            this.normal = _normal;
        }
        /// <summary>
        /// 
        /// </summary>
        public NormalLine normal
        {
            get;
            set;
        }
    }

    public class Grid
    {
        /// <summary>
        /// 是否显示直角坐标系网格。
        /// </summary>
        public bool show { get; set; }

        /// <summary>
        /// grid 组件离容器左侧的距离。
        /// </summary>
        public double left { get; set; }

        /// <summary>
        /// grid 组件离容器上侧的距离。
        /// </summary>
        public double top { get; set; }

        /// <summary>
        /// grid 组件离容器右侧的距离。
        /// </summary>
        public object right { get; set; }

        /// <summary>
        /// grid 组件离容器下侧的距离。
        /// </summary>
        public double bottom { get; set; }

        /// <summary>
        /// grid 组件的宽度。默认自适应。
        /// </summary>
        public object width { get; set; }

        ///// <summary>
        ///// grid 组件的宽度。默认自适应。
        ///// </summary>
        //public double height { get; set; }

    }
}